import { db } from "./index";
export async function addCart(data) {
  return await db.cart.add(data);
}
export async function delCart(id) {
  return await db.cart.delete(id);
}
export async function getCartList(byUserId = "", id = null) {
  return await db.cart
    .filter(el => {
      if (byUserId) {
        return el.buyUserId === byUserId;
      }
      if (id) {
        return el.id === id;
      }
      return true;
    })
    .toArray();
}
